home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
csim
/
source.lha
/
source
/
C++SIM
/
Examples
/
Queue.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-14
|
817b
|
68 lines
/*
* Copyright (C) 1993
*
* Department of Computing Science,
* The University,
* Newcastle upon Tyne,
* UK.
*/
#ifndef QUEUE_H_
#include "Queue.h"
#endif
Queue::Queue ()
{
head = 0;
length = 0;
}
Queue::~Queue () { delete head; }
boolean Queue::IsEmpty ()
{
if (head == 0)
return true;
else
return false;
}
long Queue::QueueSize () { return length; }
Job* Queue::Dequeue ()
{
if (IsEmpty())
return 0;
List* ptr = head;
head = head->next;
length--;
return ptr->work;
}
void Queue::Enqueue (Job* toadd)
{
List* ptr = head;
if (IsEmpty())
{
head = new List;
ptr = head;
}
else
{
while (ptr->next != 0)
ptr = ptr->next;
ptr->next = new List;
ptr = ptr->next;
}
ptr->next = 0;
ptr->work = toadd;
length++;
}